home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / GENCSRC.ZIP / CRYPTIC.C < prev    next >
C/C++ Source or Header  |  1987-11-21  |  2KB  |  40 lines

  1.                                          /* Chapter 4 - Program 5 */
  2. main()
  3. {
  4. int x = 0,y = 2,z = 1025;
  5. float a = 0.0,b = 3.14159,c = -37.234;
  6.  
  7.                                               /* incrementing */
  8.    x = x + 1;       /* This increments x */
  9.    x++;             /* This increments x */
  10.    ++x;             /* This increments x */
  11.    z = y++;         /* z = 2, y = 3 */
  12.    z = ++y;         /* z = 4, y = 4 */
  13.  
  14.                                               /* decrementing */
  15.    y = y - 1;       /* This decrements y */
  16.    y--;             /* This decrements y */
  17.    --y;             /* This decrements y */
  18.    y = 3;
  19.    z = y--;         /* z = 3, y = 2 */
  20.    z = --y;         /* z = 1, y = 1 */
  21.  
  22.                                               /* arithmetic op */
  23.    a = a + 12;      /* This adds 12 to a */
  24.    a += 12;         /* This adds 12 more to a */
  25.    a *= 3.2;        /* This multiplies a by 3.2 */
  26.    a -= b;          /* This subtracts b from a */
  27.    a /= 10.0;       /* This divides a by 10.0 */
  28.  
  29.                                      /* conditional expression */
  30.    a = (b >= 3.0 ? 2.0 : 10.5 );     /* This expression     */
  31.  
  32.    if (b >= 3.0)                     /* And this expression */
  33.       a = 2.0;                       /* are identical, both */
  34.    else                              /* will cause the same */
  35.       a = 10.5;                      /* result.             */
  36.  
  37.    c = (a > b?a:b);        /* c will have the max of a or b */
  38.    c = (a > b?b:a);        /* c will have the min of a or b */
  39. }
  40.